<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>02_异常处理-throw抛出异常</title>
</head>
<body>

  <script>
    class CreateError {
      constructor(message, code) {
        this.message = message;
        this.code = code;
      }
    }

    function test() {
      throw new CreateError('自定义错误', 1001);
    }

    // throw new Error('错误信息'); // 抛出异常
    // throw '错误信息'; // 抛出异常
    // throw 1001; // 抛出异常
    function test() {
      console.log("test function1");
      
      throw new Error('错误信息'); // 抛出异常

      console.log("test function2");
      
    }
    function bar() {
      test()

    }

    bar()



  </script>
  
</body>
</html>